package com.morder.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.morder.R;
import com.morder.application.AppPreference;

public class WelcomeActivity extends Activity {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.welcome);

    boolean isFirstBootFinish = AppPreference.isFirstBootFinished();
    boolean isLoginSuccess = AppPreference.isLoginSuccess();
    System.out.println("isFirstBootFinish: " + isFirstBootFinish);
    if (isFirstBootFinish && isLoginSuccess) {
      new Handler().postDelayed(new Runnable() {
        public void run() {
          RedirectMainActivity(MainActivity.class);
        }
      }, 3000);
    } else {
      new Handler().postDelayed(new Runnable() {
        public void run() {
          RedirectMainActivity(LoginActivity.class);
        }
      }, 3000);
    }
  }

  /**
   * 跳转
   */
  private void RedirectMainActivity(Class<?> clazz) {
    Intent intent = new Intent();
    intent.setClass(this, clazz);
    startActivity(intent);
    this.finish();
  }
}